package com.example.demo.repository;

import com.example.demo.entity.Joiner;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Arrays;
import java.util.List;

public interface JoinerRepository extends JpaRepository<Joiner,Integer> {
    @Query(value = "DELETE FROM joiner WHERE activity_id = %?1 AND user_id = %?2 ; ",nativeQuery = true)
    void deleteByActivity_idAndUser_id(Integer activity_id,Integer user_id);

    @Query(value = "select * from joiner where user_id = %?1 ;",nativeQuery = true)
    List<Joiner> findByUser_id(Integer user_id);

    @Query(value = "select * from joiner where activity_id = %?1 ;",nativeQuery = true)
    List<Joiner> findByActivity_id(Integer activity_id);

    @Query(value = "select * from joiner where user_id = %?1 AND quanxian = %?2 ;",nativeQuery = true)
    List<Joiner> findByUser_idAndQuanXian(Integer userid, String quanxian);
}
